package com.jgy.spring.bean.eventandlistener;

import com.jgy.entity.User;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 姜光远
 * @date 2023/3/21 10:16
 */

public class Customer1 {

    private User user;

    public Customer1() {
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getUser() {
        return user;
    }

    public Customer1(User user) {
        this.user = user;
    }

    public String event(ConfigurableApplicationContext context){

        System.out.println("模拟注册接口完成！：下面开始解耦，调用注册完成之后其他业务！");
        User user = new User();
        user.setId(1);
        user.setUsername("XXX");
        user.setPassword("XXXXXX");
        user.setAccount(new java.math.BigDecimal(100));
        user.setAddress("深地");
        Customer1 customer1 = new Customer1(user);
        context.publishEvent(customer1);
        return "OK";
    }
}
